package com.example.hasee.zhcd.Adapters;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.hasee.zhcd.R;
import com.example.hasee.zhcd.Util.GlobalParameter;

import java.util.ArrayList;
import java.util.HashMap;


/**
 * Created by hasee on 2017/9/13.
 */

public class WqdlAdapter extends BaseAdapter {
    private HashMap<String, String> map = (HashMap<String, String>) GlobalParameter.get("loginmap");
    private ArrayList<HashMap<String, String>> list;
    private LayoutInflater itemInflater;
    private Context context;
    private Holder holder;

    public WqdlAdapter(Context context, ArrayList<HashMap<String, String>> list) {
        this.context = context;
        this.list = list;
        this.itemInflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        if (convertView == null) {
            holder = new Holder();
            convertView = itemInflater.inflate(R.layout.wqdl_list_item, null);
            holder.fuser = (TextView) convertView.findViewById(R.id.fuser);
            holder.fsyd = (TextView) convertView.findViewById(R.id.fsyd);
            holder.fscy = (TextView) convertView.findViewById(R.id.fscy);
            holder.fsyj = (TextView) convertView.findViewById(R.id.fsyj);
            holder.fsbj = (TextView) convertView.findViewById(R.id.fsbj);
            holder.fsxj = (TextView) convertView.findViewById(R.id.fsxj);
            holder.fqt = (TextView) convertView.findViewById(R.id.fqt);
            holder.fdlcs = (TextView) convertView.findViewById(R.id.fdlcs);
            holder.fbl = (TextView) convertView.findViewById(R.id.fbl);
            convertView.setTag(holder);
        } else {
            holder = (Holder) convertView.getTag();
        }
        holder.fuser.setText((String) list.get(position).get("fuser"));
        holder.fsyd.setText((String) list.get(position).get("fsyd"));
        holder.fscy.setText((String) list.get(position).get("fscy"));
        holder.fsyj.setText((String) list.get(position).get("fsyj"));
        holder.fsbj.setText((String) list.get(position).get("fsbj"));
        holder.fsxj.setText((String) list.get(position).get("fsxj"));
        holder.fqt.setText((String) list.get(position).get("fqt"));
        holder.fdlcs.setText((String) list.get(position).get("fdlcs"));
        holder.fbl.setText((String) list.get(position).get("fbl"));
        return convertView;
    }

    class Holder {
        // {"fuser":"刘铁权", "fsyd":"44", "fscy":"37", "fsyj":"21", "fsbj":"", "fsxj":"", "fqt":"", "fdlcs":"45", "fbl":"24.1%"}
        private TextView fuser;
        private TextView fsyd;
        private TextView fscy;
        private TextView fsyj;
        private TextView fsbj;
        private TextView fsxj;
        private TextView fqt;
        private TextView fdlcs;
        private TextView fbl;
    }
}
